package com.rhm.dataStructure.Leetcode;/**
import	java.util.Scanner;
import	java.util.HashMap;
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 23:49
 * @Description:
 **/

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2020/2/16 23:49
 *@Description:
 **/
/*
两数之和
 */
public class Code1 {

    public static int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        int[] indexs = new int[2];
        for(int i =0;i<nums.length;i++){
            if(map.containsKey(nums[i])){
                indexs[0] =i;
                indexs[1] = map.get(nums[i]);
                return indexs;
            }
            map.put(target-nums[i],i);
        }
        return indexs;
    }
}
